Object oriented programming is used to design computer software that is easy to create, cost effective to modify, and reusable. Object-oriented programming objects are pieces of computer software that include object data and information and provide services through "object methods" (also called "object operations" or "object functions"). The object methods typically operate on private data such as instance data or object state data that the object owns. A collection of objects make up an "object class," which is sometimes called an "object type." An object class acts as a template that describes the behavior of sets of objects. An object's implementation is typically encapsulated, and is hidden from public view. Object private instance data can only be accessed by object methods of the object class. Object public instance data is accessed through a public object interface.
Object inheritance allows child object classes to be created from existing parent object superclasses. The child object classes are called subclasses or derived object classes. The subclasses inherit object information (e.g., data and state information) from the parent object superclass. Object models such as the Component Object Model (COM) and the Distributed Component Object Model (DCOM) and others typically support single and multiple object class inheritance. For single inheritance, an object class has exactly one parent. For multiple inheritance, an object class has more than one parent. Abstract object classes are object classes that are inherited by other classes. For object inheritance, object classes typically form a class hierarchy with the object "parent" being an base object class, and the object "children" being derived object classes.
There are many visual programming languages, such as Visual Basic by Microsoft Corporation of Redmond, Washington which use object-oriented components to create graphical user interfaces (GUIs) and graphical forms for organizing, inputting and outputting user data. Visual programming forms are fully functioning objects, with public and private object data and object methods. The visual programming language forms typically contain graphical data for representations of control boxes, title bars, scroll bars, and buttons provided to a user on a display device in a computer system.
The objects which make up a visual programming language form may also provide an object inheritance class hierarchy of graphical forms. There is a base object class form and derived object class forms which inherit information from the base object class form. A base object class form is typically developed to include a generic graphical form with a desired layout of graphical control boxes, title bars, scroll bars, and buttons for a generic programming application (e.g., input/output for a general application). Derived object class forms are then created from the base object class form. Derived object class forms typically include the graphical components of the base object class form with additions for a specific programming application (e.g., input/output to a specific specialized application).
Inheritance in forms and similar visual programming objects is used with a persistent state of the object. Instances of objects including the object data and method tables are typically stored in computer memory which is volatile (i.e., temporary, when a computer is turned off, or an object-oriented process terminates, they are destroyed). Some objects, like form objects, typically need to preserve some of their object state information (e.g., the state of buttons or bars on a form) from instantiation to instantiation of the object. This object state information is carried across object lifetimes as the persistent state of the object. The persistent state of an object is stored in non-volatile storage that does not disappear when the computer is turned off or the object terminates. The non-volatile storage includes storage such as a hard disk, flash memory and other storage mediums that do not lose data when the computer is turned off.
The saved persistent state of an object typically occupies no volatile memory (but may be temporarily stored in volatile memory) and is saved in a non-volatile datastore so that a later instantiation of the same object class can reload the object and recreate the original object in memory. For form objects, the persistent state includes the form level properties, plus the state of sub-objects like controls, pictures, fonts, and so forth.
Object-oriented frameworks, such Object Linking and Embedding (OLE) and ActiveX Controls by Microsoft Corporation of Redmond, Wash., allow base object classes and derived object classes to be saved in a corresponding persistent state in a non-volatile datastore. When a derived object class desires to use the persistent state information, an instance of the derived object class is created, and the object is initialized with the contents of the derived object class persistent state by reading the information from the non-volatile datastore in memory.
There are a number of problems associated with saving and loading of a derived object class from a persistence state. One problem is that changes made to a base object class may not be reflected in any of the derived object classes. For example, if changes are made to a base object class after the derived object classes have been saved in their corresponding persistent states, the base object class changes will not be reflected in the derived object classes. Another problem is that saving all of the derived object class state information wastes considerable amounts of computer resources (e.g., non-volatile storage space) since a derived object class contains all of the base object class information, and information unique to the derived object class.
Another problem associated with the saving and loading of a derived object class from a persistent state is that of connecting sub-objects (e.g., a font or color sub-object) directly to an object or using the sub-object information for inheritance by other objects. For various applications it is desirable to create sub-objects which cannot be inherited, and for other applications it is desirable to create sub-objects which can be inherited by other objects.
It is also sometimes desirable to use a derived object class as a new base object class. The new base object class would contain all of the information in the original base object class and the derived object class. New derived object classes could then be created from the new base object classes with additional specific functionality.
In accordance with an illustrative embodiment of the present invention, the problems associated with the saving and loading of a derived object class with inheritance are overcome. Methods of creating, saving and loading derived object classes with inheritance are provided. The method of creating and saving a derived object class includes creating a derived object class in memory using one or more base object classes, and determining which part of the derived object class is inherited from its base object class, and which part of the derived object class is specific and unique to the derived object class. When the derived object class is saved, the part of the derived object class that is specific to the derived object class (i.e., the difference between the base object class and the derived object class) is saved in the derived object class's persistent state in non-volatile storage. By saving only the difference between the base object class state and the derived object class state, significant computer resources are saved (e.g., non-volatile storage space).
The method of loading a derived object class includes selecting a derived object class, loading a base object class associated with the selected derived object class into memory from its persistent state in non-volatile storage. The saved differences between the base object class and the derived object class are loaded into memory using the derived object class's persistent state from non-volatile storage. By using the two-stage load process, any changes made to the base object class state are automatically reflected in the derived object class state. The saving and loading methods also allow a derived object class to be used to create a new base object class.
A new object-oriented inheritance interface Inheritable is provided with object interface members SetLoadState , SetSaveState, IsPropertyInherited and SetPropertyInherited. However, more or fewer members could also be used. The SetSaveState interface member implements the object creating and saving with inheritance described above. The SetLoadState interface member implements the object loading with inheritance described above. The IsPropertyInherited and SetPropertyInherited interfaces allow specific object properties to be marked and queried for inheritance for objects and sub-objects and will be explained in detail below. The illustrative embodiment of the present invention is used to provide inheritance in graphical forms and other visual programming objects for visual programming languages like Visual Basic. However, the invention is not limited to visual programming forms or objects, or visual programming languages, and can be used in other object-oriented frameworks which allow inheritance by derived object classes from base object classes. The illustrative embodiment of the present invention is also useful for providing object inheritance for object applications created for the Internet or an intranet (e.g., ActiveX control objects).
The foregoing and other features and advantages of an illustrative embodiment of the present invention will be more readily apparent from the following detailed description, which proceeds with reference to the accompanying drawings.